require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
console.log(userInfo)
var vm = new Vue({
    el:"#forwardResult",
    data:{
        loadFlag:false,
        circleName:"",
        circleList:{}, //圈子列表
        postInfo:{}, //帖子详情
        list:{
            loginUid:userInfo.id,
            circleId:"",  //圈子id
            modelId:"",  //帖子id
            model:"4",   //类型 1视频，2广告，3游记，4帖子，5圈子，6个人，7城市，8企业，9简历
            modelName:"",  //模块标题
            title:"",     //标题
            coverImgSrc:""  //封面
        }
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        this.list.modelId=this.searchObject&&this.searchObject.postId;
        this.list.circleId=this.searchObject&&this.searchObject.circleId;
        this.circleName=decodeURI(this.searchObject&&this.searchObject.circleName);
        this.getPost();
    },
    methods:{
        //后退
        getBack: function () {
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //获取帖子详情
        getPost:function() {
            var that = this;
            var data = {
                loginUid: that.list.loginUid,
                postId: that.list.modelId
            };
            this.ajax({url:"/friend/getPost", data: data, dataType: "json", method: "post"}, function (b) {
                if (b.json.code == 0 && b.json.data) {
                    that.postInfo= b.json.data;
                    that.list.modelName=that.postInfo.title;
                    that.list.coverImgSrc=that.postInfo.coverImgSrc;
                    //console.log(that.categoryList)
                } else {
                    vm.$refs.prompt.toast("获取帖子详情失败！")
                }
            });
        },
        //圈子列表
        forwardPost:function(){
            var that=this;
            if(!that.list.title){
                vm.$refs.prompt.toast("请输入想说的话！");
                return false;
            }
            this.ajax({url:"/friend/forwardPost",data:that.list,dataType:"json",method:"post"},function(b){
                if(b.json.code==0){
                    vm.$refs.prompt.toast("操作成功！");
                    that.getBack();
                }else{
                    vm.$refs.prompt.toast("操作失败！");
                }
            });
        }
    }
    ,watch: {}
});